<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .carowner_1,.carowner_2{display: block;margin-top: 10px;width:100%;height:25px;}
    .carowner_2{margin-left:0px;}
    .select_model{
        -moz-appearance: none;background: rgba(0, 0, 0, 0) url("http://img3.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 110px 5px;
        border: 1px solid #d7d7d7; color:#7f7f7f;float: left;height: 26px;line-height: 26px;margin-right: 8px;text-indent: 2px;width: 130px;}
    .select2-container .select2-choice {
        background: rgba(0, 0, 0, 0) url("http://img1.isou365.cn/paimai/yunying/images/sanjiao.jpg") no-repeat scroll 140px 5px;
        border: 1px solid #d7d7d7;  color: #444;  display: block;  height: 24px;  line-height: 24px;
        overflow: hidden;  padding: 0 0 0 8px;  position: relative;  text-decoration: none;  white-space: nowrap;  width: 154px;
    }
    .text_model{  border: 1px solid #d7d7d7;float: left;height: 24px;  line-height: 24px;margin: 0 10px 10px 0;text-align: center;width: 150px;  }
    .search_btn{height:26px;line-height:26px;
                background: #20ab4f none repeat scroll 0 0;border-radius: 3px;border:medium none;color: #fff;
                margin-left: 7px;padding: 0;width: 60px;float:left;}
    .check_time{float:left;}
    .table .mcenter{vertical-align: middle;text-align: center;}
    #bidding_start_time,#bidding_end_time{border: 1px solid #d7d7d7;height: 24px;line-height: 24px;margin:0 5px;text-align: center;width: 150px;}
    #check_start_time,#check_end_time{border: 1px solid #d7d7d7;height: 24px;line-height: 24px;margin:0 5px;text-align: center;width: 150px;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="cxtj.clcx" />
    <div class="mianR">
        <div class='carowner_1'>
            <div class="check_time">
                从<input type="text" name="start_time" placeholder="请选择检测时间" value="" class="xiaci xin-text1" id="check_start_time" readonly>
                到<input type="text" name="end_time"  placeholder="请选择检测时间" value="" class="xiaci xin-text1" id="check_end_time" readonly />
            </div>
            <select name="car_status" id="car_status" class="select_model">
                <option value="-1">请选择车辆状态</option>
                <option value="0">待上传协议</option>
                <option value="1">待审核</option>
                <option value="2">审核失败</option>
                <option value="3">审核驳回</option>
                <option value="4">待拍卖</option>
                <option value="5">拍卖中</option>
                <!--<option value="6">流拍</option>-->
                <option value="7">待重拍</option>
                <option value="9">交易成功</option>
                <option value="8">交易失败</option>
            </select>
            <select name="pay_status" id="pay_status" class="select_model">
                <option value="0">请选择付款状态</option>
                <volist name="order_pay_status" id="ops">
                    <option value="{$key}">{$ops}</option>
                </volist>
            </select>
            <select name="location_area" id="location_area" class="select_model" >
                <if condition="count($bc_city) gt 1">
                    <option value="0">请选择所在地</option>
                </if>
                <foreach name="bc_city" item="vo" key="k">
                    <option value="{$k}">{$vo}</option>
                </foreach>
            </select>
            <!--<select name="location_area" id="location_area" class="select_model">-->
                <!--<option value="0">请选择车辆所在地</option>-->
                <!--<option value="110000">北京</option>-->
                <!--<option value="131082">三河</option>-->
                <!--<option value="131000">廊坊</option>-->
                <!--<option value="131022">固安</option>-->
                <!--<option value="130681">涿州</option>-->
                <!--<option value="131024">香河</option>-->
            <!--</select>-->

            <!--<select id="from" name="from" class="select_model">-->
            <!--<option value="0">请选择渠道来源</option>-->
            <!--<?php foreach($pfrom as $item):?>-->
            <!--<option value="{$item.from_id}">{$item.from_name}</option>-->
            <!--<?php endforeach;?>-->
            <!--</select>-->

            <!--<select id="comeFrom" name="comefrom" class="select_model">-->
            <!--<option value="-2">请选择具体来源</option>-->
            <!--</select>-->
            <div class="source_input">
                <input type="text"  name="comefrom" value="" placeholder="请选择渠道来源" readOnly />
                <div class="source">
                    <ul>
                        <?php foreach($pfrom as $item):?>
                            <li date="{$item.from_id}">{$item.from_name}</li>
                        <?php endforeach;?>
                    </ul>
                </div>
                <div class="sourceCity">
                    <ul>
                        <foreach name="bc_city" item="vo" key="k">
                            <li date-city="{$k}">{$vo}</li>
                        </foreach>
                    </ul>
                </div>
                <div class="sourceTab">
                    <foreach name="comefrom_list" item="cl" key="k">
                        <div class="sourceList" date-pid="{$k}">
                            <ul>
                                <foreach name="cl" item="clv">
                                    <li date-id="{$clv.from_id}">{$clv.from_name}</li>
                                </foreach>
                            </ul>
                        </div>
                    </foreach>

                    <div class="sourceList siSdian">
                        <foreach name="city_fours_list" item="cfl" key="k">
                            <ul style="display: none;" date-code-city="{$k}">
                                <foreach name="cfl" item="cflv">
                                    <li date-id="{$cflv.from_id}">{$cflv.from_name}</li>
                                </foreach>
                            </ul>
                        </foreach>
                    </div>
                </div>
            </div>

        </div>
        <div class='carowner_2'>
            <input type="text" id="car_no" name="car_no" value="" placeholder="车辆编号" class="text_model"/>
            <input type="text" id="car_level" name="car_level" value="" placeholder="级别" class="text_model"/>
            <input type="text" id="car_plate_number" name="car_plate_number" value="" placeholder="车牌号" class="text_model"/>
<!--            <input type="text" id="car_vin" name="car_vin" value="" placeholder="车架号" class="text_model"/>-->
            <select name="branch_company" class="branch_company select_model" >
                <if condition="$branch_id eq 0">
                    <option value="0">请选择所属分公司</option>
                </if>
                <foreach name="bc_list" item="vo" key="k">
                    <option value="{$k}" <?=$k == $branch_id ? 'selected' : ''?> >{$vo}</option>
                </foreach>
            </select>
            <select name="checker_id" id="checker" style="width:162px;float:left;margin-left:0px;">
                <option value=''>请选择评估师</option>
                <volist name='checker' id='ce'>
                     <option value="{$ce.emp_id}">{$ce.real_name}</option>
                </volist>
            </select>	
            <input type="button" id="search" value="搜索" class="search_btn">
            <div class='clear'></div>
        </div>

        <div class="yuList" >
            <div class="listBox" id="listBox"></div>
        </div>
    </div>
    <div id="showOptionChecker" style="display:none">
        <volist name="checker" id="vo">
            <option class="{$vo['branch_id']}" value="{$vo['emp_id']}" >{$vo['real_name']}</option>
        </volist>
    </div>

    <!--<div id="showOption" style="display:none">-->
        <!--<volist name="from" id="vo">-->
            <!--<option class="{$vo['pid']}" value="{$vo['from_id']}" >{$vo['from_name']}</option>-->
        <!--</volist>-->
    <!--</div>-->
    <div class="clear"></div>
    <include file="Public/foot" />
    <script type="text/javascript">
        $(".branch_company").change(function(){
            $(".select2-chosen").html('请选择评估师');
        });
        $("body,html").click(function(event) {
            $(".sourceCity").hide();
            $(".sourceTab .sourceList").hide();
            $(".source").hide();
            event.stopPropagation();
        });

        $(".source_input").click(function(event) {
            event.stopPropagation();
        });
        $(".source_input input").val("");
        $(".source_input input").click(function() {
//            $(this).val("");
            if($(".source").css("display")=="none"){
                $(".source").fadeIn();
            }else{
                $(".source").hide();
            }
            $(".sourceCity").hide();
            $(".sourceTab .sourceList").hide();
        });
        var index;
        var text;
        var dateIndex;
        $(".source ul li").click(function() {
            index=$(".source ul li").index(this);
            text=$(this).html();
            dateIndex=$(this).attr("date");
            if(dateIndex==5){
                $(".sourceCity").fadeIn();
                $(".sourceTab .sourceList").hide();
            }else{
                $(".sourceCity").hide();
                $(".sourceTab .sourceList[date-pid='"+dateIndex+"']").fadeIn().siblings().hide();
            }
            $(this).parent().parent().hide();
        });
        var city;
        var cityIndex;
        $(".sourceCity ul li").click(function(i){
            city=$(this).html();
            $(this).parent().parent().hide();
            cityIndex=$(this).attr("date-city");
            $(".sourceTab .siSdian").fadeIn().find("ul[date-code-city='"+cityIndex+"']").fadeIn().siblings().hide();
        })
        $(".sourceList ul li").click(function(){
            $(this).parent().parent().hide();
            if(index==3){
                $(".source_input input").val(text+" - "+city+" - "+$(this).html());
                $(".source_input input").attr("real-value",$(this).attr("date-id"));
            }else{
                $(".source_input input").val(text+" - "+$(this).html());
                $(".source_input input").attr("real-value",$(this).attr("date-id"));
            }
        });
        
        $("#checker").select2();  
        $("#check_start_time").ymdateplugin({
            changeMonth: true,
            changeYear: true
        });
        $("#check_end_time").ymdateplugin({
            changeMonth: true,
            changeYear: true
        });

        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null)
                return unescape(r[2]);
            return null; //返回参数值
        }
        get_list();
        function get_list(isSearch) {
            var url = get_url();
            var purl = '';
            if (isSearch != 1) {
                var p = getUrlParam('p'); 
                if (p != null) {
                    purl = "?p=" + p;
                } else {
                    purl = "?p=1";
                }
            }
            $.get("/CarCheck/car_list" + purl, encodeURI(url), function (data) {
                $("#listBox").html(data);
            }, "html");
        }

        function get_page(p) {
            var url = get_url();
            url += "&p=" + p;
            $.get("/CarCheck/car_list", encodeURI(url), function (data) {
                $("#listBox").html(data);
            }, "html");
        }
        $(".search_btn").on("click", function () {
            var isSearch = 1;
            get_list(isSearch);
        });
        function get_url() {
            var url = "";
            var start_time = $("input[name='start_time']").val();
            var end_time = $("input[name='end_time']").val();
            var car_status = $("#car_status").val();
            var pay_status = $("#pay_status").val();
            var location_area = $("#location_area").val();
            var comefrom = $("input[name='comefrom']").attr('real-value');
            var car_no = $("#car_no").val();
            var car_level = $("#car_level").val();
            var car_plate_number = $("#car_plate_number").val();
            var checker = $("#checker").val();
//            var car_vin = $("#car_vin").val();
            if (start_time) {
                url += '&start_time=' + start_time;
            }
            if (end_time) {
                url += '&end_time=' + end_time;
            }
            if (car_status) {
                url += '&car_status=' + car_status;
            }
            if (pay_status) {
                url += '&pay_status=' + pay_status;
            }
            if (location_area) {
                url += '&location_area=' + location_area;
            }
            if (comefrom) {
                url += '&comefrom=' + comefrom;
            }
            if (car_no) {
                url += '&car_no=' + car_no;
            }
            if(car_level){
                url += '&car_level='+car_level;
            }
            if(car_plate_number){
                url += '&car_plate_number='+car_plate_number;
            }
            if(checker){
                url += '&checker_id=' + checker;
            }
//            if (car_vin) {
//                url += '&car_vin=' + car_vin;
//            }
            return url;
        }
        $("#from").change(function () {
            var value = $(this).val(); //获取渠道当前下拉列表选中的值
            //隐藏所有下拉列表的值
            $("#comeFrom option").each(function () {
                if ($(this).val() != '') {
                    $(this).remove();
                }
            });

            //显示具体渠道下拉列表
            $("#showOption option").each(function () {
                if ($(this).val() == '' || $(this).attr("class") == value) { //通过判断class名称判断是否显示
                    $("#comeFrom").append($(this).clone(true));              //为Select追加一个Option(下拉项)
                    if ($(this).val() == '') {
                        $(this).prop("selected", true);
                    }
                }
            });
        });

        $('.branch_company').change(function(){
            var bc_value = $(this).val(); //获取渠道当前下拉列表选中的值
            //隐藏所有下拉列表的值
            $("#checker option").each(function(){
                if($(this).val()!='0'){
                    $(this).remove();
                }
            });
            //显示具体渠道下拉列表
            $("#checker").empty()
                    .append('<option value="0" style="color: rgb(0, 0, 0);">请选择评估师</option>')
                    .append($("#showOptionChecker ." + bc_value).clone());
        });
        //初始化分公司下的评估师列表
        init_checker_list();
        function init_checker_list(){
            var branch_obj = $('.branch_company');
            var branch_id = branch_obj.val();
            //显示具体渠道下拉列表
            $("#checker").empty()
                    .append('<option value="0" style="color: rgb(0, 0, 0);">请选择评估师</option>')
                    .append($("#showOptionChecker ."+branch_id).clone());
        }

    </script>